package com.kyhd.audio.dao.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;
import lombok.ToString;

@ToString
@Data
@Entity
@Table(/*schema = "novel",*/ name = "wm_novel_content",
indexes={@Index(columnList="content_id", name="content_id_2"),
        @Index(columnList= "content_chapter_id,content_novel_id", name="chapter_id")
		},
uniqueConstraints = {
	    @UniqueConstraint(columnNames = {"content_id"}) 
	    }
)
@EntityListeners(AuditingEntityListener.class)
public class Novel {
    @Id
//    @GeneratedValue(strategy = GenerationType.UUID) //mysql数据库表ID需设置为auto_increment
    @Column(name = "content_id", nullable = false, updatable = false
    ,columnDefinition="varchar(50)")
    private String content_id;
    
	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(columnDefinition = "TEXT", name = "content",length=100000,nullable = false, updatable = true)
	private String content;
	
    @Column(name = "content_chapter_id", nullable = false, updatable = false
    ,columnDefinition="varchar(50)")
    private String content_chapter_id;

    @Column(name = "content_novel_id", nullable = false, updatable = false
    ,columnDefinition="varchar(10)")
    private String content_novel_id;

    @Column(name = "audio", nullable = false, updatable = true)
    private int audio;
}
